﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Libs.HR;

public partial class Pages_Hr_Employees_Report : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        AppUtils.CheckLogin();
        Title = Title + " - Xem báo cáo";
        if (!IsPostBack)
        {
            init();
            BindData();
        }
    }

    private void init()
    {
        int year = 2012;
        for (int i = DateTime.Now.Year; i >= year; i--)
        {
            drpYear.Items.Add(new ListItem("Năm " + i.ToString(), i.ToString()));
        }

        for (int i = 1; i <= 12; i++)
        {
            drpMonth.Items.Add(new ListItem("Tháng " + i.ToString(), i.ToString()));
        }

        drpMonth.SelectedValue = DateTime.Now.Month.ToString();
    }

    private void BindData()
    {
        var _EmployeeReport = new EmployeeReport();
        int reportTime = Convert.ToInt32(drpYear.SelectedValue) * 100 + Convert.ToInt32(drpMonth.SelectedValue);
        rptList.DataSource = _EmployeeReport.TList(reportTime);
        rptList.DataBind();
    }

    protected void btView_Click(object sender, EventArgs e)
    {
        BindData();
    }
}
